import { createRouter, createWebHashHistory } from 'vue-router'
import {useAuthStore} from "@/stores/auth"

import frame_routers from "@/router/frame"
import login_routers from "@/router/login"


const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: frame_routers.concat(login_routers)
})

router.beforeEach((to,from)=>{
  const authstore = useAuthStore()
  if(!authstore.is_logined && to.name != "login"){
      return {name:"login"}
  }
})

export default router


